<?php
namespace Components\Account\User\Wallet\Transfer;

class Service {
	public function pager($parameters = [], $limit = 10, $page = 1) {
		$builder = (new \Phalcon\Mvc\Model\Query\Builder($parameters)) -> from([
			'account_wallet_transfer' => __NAMESPACE__ . '\\Model',
			'from_account' => 'Components\\Account\\User\\Model',
			'to_account' => 'Components\\Account\\User\\Model'
		])
		-> columns('account_wallet_transfer.*, from_account.account AS from_account_account, to_account.account AS to_account_account')
		-> andWhere('account_wallet_transfer.from_user_id = from_account.user_id AND account_wallet_transfer.to_user_id = to_account.user_id');

		return ['code' => 0, 'pager'=>(new \Phalcon\Paginator\Adapter\QueryBuilder([
			'builder' => $builder,
			'limit' => $limit,
			'page' => $page
		])) -> getPaginate()];
	}
}
